#include <stdio.h>
#include <string.h>

void get_next(char *t, int *next)
{
    int i = 1, j = 0;
    next[1] = 0;
    while (i < t[0])
    {
        if (j == 0 || t[i] == t[j])
        {
            i++;
            j++;
            next[i] = j;
        }
        else
        {
            j = next[j];
        }
    }
}
int main(int argc, const char *argv[])
{
    char str[0x1000], key[0x100];
    if (argc < 3)
    {
        perror("./test <str> <key>\n");
        return 1;
    }
    strcpy(str + 1, argv[1]);
    strcpy(key + 1, argv[2]);
    str[0] = strlen(str + 1);
    key[0] = strlen(key + 1);
    int next[0x1000];
    get_next(key, next);
    for (int i = 1; i <= key[0]; i++)
    {
        printf("%d ", next[i]);
    }
    int i = 1, j = 1;
    while (i <= str[0] && j <= key[0])
    {
        if (j == 0 || str[i] == key[j])
        {
            i++;
            j++;
        }
        else
        {
            j = next[j];
        }
    }
    if (j > key[0])
    {
        printf("Yes\n");
        printf("loc:%d\n", i - key[0]);
    }
    else
    {
        printf("No\n");
    }
    return 0;
}